﻿@*<script src="~/admui-13945148017-1592211513218/vendor/bootstrap-sweetalert/sweetalert.min.js"></script>*@
@*<script src="~/admui-13945148017-1592211513218/themes/global/js/components/bootstrap-sweetalert.min.js"></script>*@
@*<script src="~/admui-13945148017-1592211513218/js/examples/components/advanced/bootbox-sweetalert.min.js"></script>*@
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-sweetalert/sweetalert.js"></script>
<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-sweetalert.js"></script>
<script src="~/admui-13945148017-1592211513218/public/js/examples/components/advanced/bootbox-sweetalert.js"></script>
<script src="~/admui-13945148017-1592211513218/public/js/tsk/sweetalert.min.js"></script>

<script>
    $(document).ready(function () {
        $("#SpanKeHu").click();
        var KeHuId = getQuery("Id");
        if (KeHuId != null) {
            $("#div_KeHuId").text(KeHuId);
            BindKeHu(KeHuId);
        }

    });


    function Add() {

        var XingMing = $("#txt_KeHuXingMing").val();
        var ShouJiHaoMa = $("#txt_ShouJiHaoMa").val();
        var YiXiangDengJi = $("#txt_YiXiangDengJi").val();
        var LianMingKeHu = $("#txt_LianMingKeHu").val();
        var XingBie = $("#dl_XingBie").find("option:selected").val();
        var NianLing = $("#txt_NianLing").val();
        var ZhengJianLeiXing = $("#dl_ZhengJianLeiXing").find("option:selected").val();
        var ZhengJianHaoMa = $("#txt_ZhengJianHaoMa").val();
        var RenZhiMeiTi = $("#txt_RenZhiMeiTi").val();
        var KeHuBeiZhu = $("#txt_KeHuBeiZhu").val();
        var GeRenBiaoQian = $("#txt_GeRenBiaoQian").val();
        var ZhiYeShenFen = $("#txt_ZhiYeShenFen").val();
        var JiaTingJieGou = $("#txt_JiaTingJieGou").val();
        var JiaoYuChengDu = $("#txt_JiaoYuChengDu").val();
        var HunYinZhuangKuang = $("#txt_HunYinZhuangKuang").val();
        var ShouRuQingKuang = $("#txt_ShouRuQingKuang").val();
        var GongZuoQuYu = $("#txt_GongZuoQuYu").val();
        var GongZuoDiZhi = $("#txt_GongZuoDiZhi").val();
        var JuZhuQuYu = $("#txt_JuZhuQuYu").val();
        var JuZhuDiZhi = $("#txt_JuZhuDiZhi").val();
        var YiXiangYongTu = $("#txt_YiXiangYongTu").val();
        var YiXiangYeTai = $("#txt_YiXiangYeTai").val();
        var YiXiangHuXing = $("#txt_YiXiangHuXing").val();
        var YiXiangLouCeng = $("#txt_YiXiangLouCeng").val();
        var YiXiangMianJi = $("#txt_YiXiangMianJi").val();
        var YiXiangTaoShu = $("#txt_YiXiangTaoShu").val();
        var YiXiangDanJia = $("#txt_YiXiangDanJia").val();
        var YiXiangZongJia = $("#txt_YiXiangZongJia").val();
        var GuanZhuNeiRong = $("#txt_GuanZhuNeiRong").val();
        var slt_kehulaiyuan = $("#slt_kehulaiyuan").find("option:selected").val();
        //alert(XingMing);

        var zhengshuxiaoshu = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;

        if ($.trim(XingMing).length == 0) {
            swal("失败提示!", "姓名不能为空!", "error");
            return;
        } if (!(/^1[3456789]\d{9}$/.test(ShouJiHaoMa))) {
            swal("失败提示!", "请输入正确的手机号码!", "error");
            return;
        } if ($.trim(YiXiangHuXing).length == 0) {
            swal("失败提示!", "意向户型不能为空!", "error");
            return;
        } if (!(zhengshuxiaoshu.test(YiXiangMianJi))) {
            swal("失败提示!", "请输入正确的面积!", "error");
            return;
        } if (!zhengshuxiaoshu.test(YiXiangZongJia)) {
            swal("失败提示!", "请输入正确的价格!", "error");
            return;
        }

        var KeHuId = $("#div_KeHuId").text();
        if (KeHuId == 0) {
            $.ajax({
                type: "POST",
                url: "../KeHu/AddKeHu",
                cache: false,  //禁用缓存
                data: { "XingMing": "" + XingMing + "", "ShouJiHaoMa": "" + ShouJiHaoMa + "", "NianLing": "" + NianLing + "", "YiXiangDengJi": "" + YiXiangDengJi + "", "LianMingKeHu": "" + LianMingKeHu + "", "XingBie": "" + XingBie + "", "ZhengJianLeiXing": "" + ZhengJianLeiXing + "", "ZhengJianHaoMa": "" + ZhengJianHaoMa + "", "RenZhiMeiTi": "" + RenZhiMeiTi + "", "KeHuBeiZhu": "" + KeHuBeiZhu + "", "GeRenBiaoQian": "" + GeRenBiaoQian + "", "ZhiYeShenFen": "" + ZhiYeShenFen + "", "JiaTingJieGou": "" + JiaTingJieGou + "", "JiaoYuChengDu": "" + JiaoYuChengDu + "", "HunYinZhuangTai": "" + HunYinZhuangKuang + "", "ShouRuQingKuang": "" + ShouRuQingKuang + "", "GongZuoQuYu": "" + GongZuoQuYu + "", "GongZuoDiZhi": "" + GongZuoDiZhi + "", "JuZhuQuYu": "" + JuZhuQuYu + "", "JuZhuDiZhi": "" + JuZhuDiZhi + "", "YiXiangYongTu": "" + YiXiangYongTu + "", "YiXiangYeTai": "" + YiXiangYeTai + "", "YiXiangHuXing": "" + YiXiangHuXing + "", "YiXiangLouCeng": "" + YiXiangLouCeng + "", "YiXiangMianJi": "" + YiXiangMianJi + "", "YiXiangTaoShu": "" + YiXiangTaoShu + "", "YiXiangDanJia": "" + YiXiangDanJia + "", "YiXiangZongJia": "" + YiXiangZongJia + "", "GuanZhuNeiRong": "" + GuanZhuNeiRong + "", "slt_kehulaiyuan": "" + slt_kehulaiyuan + "" },  //传入组装的参数
                dataType: "text",
                success: function (result) {
                    if (result == "5") {
                        swal("成功提示!", "保存成功!", "success");
                    } else if (result == "-2") {
                        swal("失败提示!", "当前客户为实现不能添加客户!", "success");
                    } else if (result == "-3") {
                        swal("失败提示!", "当前客户为实现不能添加客户!", "success");
                    } else if (result == "-4") {
                        swal("失败提示!", "客户失败!", "success");
                    } else {
                            swal("失败提示!", "保存失败!", "error");
                    }
                    //if (result == "success") {
                    //    swal("成功提示!", "保存成功!", "success");
                    //    //setTimeout(function () { window.location.href = "/Index/Index.aspx"; }, 2000);
                    //}
                    //else {
                    //    swal("失败提示!", "保存失败!", "error");
                    //}
                }
            });
        }
        else {
            $.ajax({
                type: "POST",
                url: "../KeHu/UpdateKeHu",
                cache: false,  //禁用缓存
                data: { "Id": "" + KeHuId + "", "XingMing": "" + XingMing + "", "ShouJiHaoMa": "" + ShouJiHaoMa + "", "NianLing": "" + NianLing + "", "YiXiangDengJi": "" + YiXiangDengJi + "", "LianMingKeHu": "" + LianMingKeHu + "", "XingBie": "" + XingBie + "", "ZhengJianLeiXing": "" + ZhengJianLeiXing + "", "ZhengJianHaoMa": "" + ZhengJianHaoMa + "", "RenZhiMeiTi": "" + RenZhiMeiTi + "", "KeHuBeiZhu": "" + KeHuBeiZhu + "", "GeRenBiaoQian": "" + GeRenBiaoQian + "", "ZhiYeShenFen": "" + ZhiYeShenFen + "", "JiaTingJieGou": "" + JiaTingJieGou + "", "JiaoYuChengDu": "" + JiaoYuChengDu + "", "HunYinZhuangTai": "" + HunYinZhuangKuang + "", "ShouRuQingKuang": "" + ShouRuQingKuang + "", "GongZuoQuYu": "" + GongZuoQuYu + "", "GongZuoDiZhi": "" + GongZuoDiZhi + "", "JuZhuQuYu": "" + JuZhuQuYu + "", "JuZhuDiZhi": "" + JuZhuDiZhi + "", "YiXiangYongTu": "" + YiXiangYongTu + "", "YiXiangYeTai": "" + YiXiangYeTai + "", "YiXiangHuXing": "" + YiXiangHuXing + "", "YiXiangLouCeng": "" + YiXiangLouCeng + "", "YiXiangMianJi": "" + YiXiangMianJi + "", "YiXiangTaoShu": "" + YiXiangTaoShu + "", "YiXiangDanJia": "" + YiXiangDanJia + "", "YiXiangZongJia": "" + YiXiangZongJia + "", "GuanZhuNeiRong": "" + GuanZhuNeiRong + "", "slt_kehulaiyuan": "" + slt_kehulaiyuan + "" },  //传入组装的参数
                dataType: "text",
                success: function (result) {
                    if (result == "success") {
                        swal("成功提示!", "保存成功!", "success");
                        //setTimeout(function () { window.location.href = "/Index/Index.aspx"; }, 2000);
                    }
                    else {
                        swal("失败提示!", "保存失败!", "error");
                    }
                }
            });
        }




    }

    function BindKeHu(KeHuId) {
        $.ajax({
            url: "../KeHu/ReturnKeHuJson",
            data: { "Id": "" + KeHuId + "" },
            type: "post",
            dataType: "json",
            success: function (response) {
                console.log(response);
                $(response).each(function (key) {
                    $("#txt_KeHuXingMing").val(response[key].KeHuXingMing);
                    $("#txt_ShouJiHaoMa").val(response[key].ShouJiHaoMa);
                    $("#txt_YiXiangDengJi").val(response[key].YiXiangDengJi);
                    $("#txt_LianMingKeHu").val(response[key].LianMingKeHu);
                    $("#dl_XingBie").val(response[key].XingBie);
                    $("#txt_NianLing").val(response[key].NianLing);
                    $("#dl_ZhengJianLeiXing").val(response[key].ZhengJianLeiXing);
                    $("#txt_ZhengJianHaoMa").val(response[key].ZhengJianHaoMa);
                    $("#txt_RenZhiMeiTi").val(response[key].RenZhiMeiTi);
                    $("#txt_KeHuBeiZhu").val(response[key].KeHuBeiZhu);
                    $("#txt_GeRenBiaoQian").val(response[key].GeRenBiaoQian);
                    $("#txt_ZhiYeShenFen").val(response[key].ZhiYeShenFen);
                    $("#txt_JiaTingJieGou").val(response[key].JiaTingJieGou);
                    $("#txt_JiaoYuChengDu").val(response[key].JiaoYuChengDu);
                    $("#txt_HunYinZhuangKuang").val(response[key].HunYinZhuangTai);
                    $("#txt_ShouRuQingKuang").val(response[key].ShouRuQingKuang);
                    $("#txt_GongZuoQuYu").val(response[key].GongZuoQuYu);
                    $("#txt_GongZuoDiZhi").val(response[key].GongZuoDiZhi);
                    $("#txt_JuZhuQuYu").val(response[key].JuZhuQuYu);
                    $("#txt_JuZhuDiZhi").val(response[key].JuZhuDiZhi);
                    $("#txt_YiXiangYongTu").val(response[key].YiXiangYongTu);
                    $("#txt_YiXiangYeTai").val(response[key].YiXiangYeTai);
                    $("#txt_YiXiangHuXing").val(response[key].YiXiangHuXing);
                    $("#txt_YiXiangLouCeng").val(response[key].YiXiangLouCeng);
                    $("#txt_YiXiangMianJi").val(response[key].YiXiangMianJi);
                    $("#txt_YiXiangTaoShu").val(response[key].YiXiangTaoShu);
                    $("#txt_YiXiangDanJia").val(response[key].YiXiangDanJia);
                    $("#txt_YiXiangZongJia").val(response[key].YiXiangZongJia);
                    $("#txt_GuanZhuNeiRong").val(response[key].GuanZhuNeiRong);
                    $("#slt_kehulaiyuan").val(response[key].BeiZhu2);
                })
            }
        });
    }

    function getQuery(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }

</script>
<div id="div_KeHuId" style="display:none;">0</div>
<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">客户管理</h1>
            <ol class="breadcrumb">

                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">客户管理</a>
                </li>
                <li class="breadcrumb-item active">客户基本信息</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-body container-fluid">
                    <div class="row row-lg">
                        <div class="col-md-12">

                            <div class="example-wrap">

                                <div class="example">
                                    <div autocomplete="off">
                                        <div class="row">
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_KeHuXingMing">姓名</label>
                                                <input type="text" class="form-control" id="txt_KeHuXingMing" name="txt_KeHuXingMing"
                                                       placeholder="姓名" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_LianXiFangShi">手机号码</label>
                                                <input type="text" class="form-control" id="txt_ShouJiHaoMa" name="txt_ShouJiHaoMa"
                                                       placeholder="手机号码" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_YiXiangDengJi">意向等级</label>
                                                <input type="text" class="form-control" id="txt_YiXiangDengJi" name="txt_YiXiangDengJi"
                                                       placeholder="意向等级" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_LianMingKeHu">联名客户</label>
                                                <input type="text" class="form-control" id="txt_LianMingKeHu" name="txt_LianMingKeHu"
                                                       placeholder="联名客户" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_NianLing">年龄</label>
                                                <input type="text" class="form-control" id="txt_NianLing" name="txt_NianLing"
                                                       placeholder="年龄" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_XingBie">性别</label>
                                                <select class="form-control" id="dl_XingBie"><option value="男">男</option><option value="女">女</option></select>
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_ZhengJianLeiXing">证件类型</label>
                                                <select class="form-control" id="dl_ZhengJianLeiXing"><option value="身份证">身份证</option></select>
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_ZhengJianHaoMa">证件号码</label>
                                                <input type="text" class="form-control" id="txt_ZhengJianHaoMa" name="txt_ZhengJianHaoMa"
                                                       placeholder="证件号码" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="forRenZhiMeiTi">认知媒体</label>
                                                <input type="text" class="form-control" id="txt_RenZhiMeiTi" name="txt_RenZhiMeiTi"
                                                       placeholder="认知媒体" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_KeHuBeiZhu">客户备注</label>
                                                <input type="text" class="form-control" id="txt_KeHuBeiZhu" name="txt_KeHuBeiZhu"
                                                       placeholder="客户备注" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_GeRenBiaoQian">个人标签</label>
                                                <input type="text" class="form-control" id="txt_GeRenBiaoQian" name="txt_GeRenBiaoQian"
                                                       placeholder="个人标签" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_ZhiYeShenFen">职业身份</label>
                                                <input type="text" class="form-control" id="txt_ZhiYeShenFen" name="txt_ZhiYeShenFen"
                                                       placeholder="职业身份" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_JiaTingJieGou">家庭结构</label>
                                                <input type="text" class="form-control" id="txt_JiaTingJieGou" name="txt_JiaTingJieGou"
                                                       placeholder="家庭结构" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_JiaoYuChengDu">教育程度</label>
                                                <input type="text" class="form-control" id="txt_JiaoYuChengDu" name="txt_JiaoYuChengDu"
                                                       placeholder="教育程度" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_HunYinZhuangKuang">婚姻状况</label>
                                                <input type="text" class="form-control" id="txt_HunYinZhuangKuang" name="txt_HunYinZhuangKuang"
                                                       placeholder="婚姻状况" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_ShouRuQingKuang">收入情况</label>
                                                <input type="text" class="form-control" id="txt_ShouRuQingKuang" name="txt_ShouRuQingKuang"
                                                       placeholder="收入情况" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_GongZuoQuYu">工作区域</label>
                                                <input type="text" class="form-control" id="txt_GongZuoQuYu" name="txt_GongZuoQuYu"
                                                       placeholder="工作区域" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_GongZuoDiZhi">工作地址</label>
                                                <input type="text" class="form-control" id="txt_GongZuoDiZhi" name="txt_GongZuoDiZhi"
                                                       placeholder="工作地址" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_JuZhuQuYu">居住区域</label>
                                                <input type="text" class="form-control" id="txt_JuZhuQuYu" name="txt_JuZhuQuYu"
                                                       placeholder="居住区域" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_JuZhuDiZhi">居住地址</label>
                                                <input type="text" class="form-control" id="txt_JuZhuDiZhi" name="txt_JuZhuDiZhi"
                                                       placeholder="居住地址" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_YiXiangYongTu">意向用途</label>
                                                <input type="text" class="form-control" id="txt_YiXiangYongTu" name="txt_YiXiangYongTu"
                                                       placeholder="意向用途" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_YiXiangYeTai">意向业态</label>
                                                <input type="text" class="form-control" id="txt_YiXiangYeTai" name="txt_YiXiangYeTai"
                                                       placeholder="意向业态" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_YiXiangHuXing">意向户型</label>
                                                <input type="text" class="form-control" id="txt_YiXiangHuXing" name="txt_YiXiangHuXing"
                                                       placeholder="意向户型" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_YiXiangLouCeng">意向楼层</label>
                                                <input type="text" class="form-control" id="txt_YiXiangLouCeng" name="txt_YiXiangLouCeng"
                                                       placeholder="意向楼层" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_YiXiangMianJi">意向面积</label>
                                                <input type="text" class="form-control" id="txt_YiXiangMianJi" name="txt_YiXiangMianJi"
                                                       placeholder="意向面积" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_YiXiangTaoShu">意向套数</label>
                                                <input type="text" class="form-control" id="txt_YiXiangTaoShu" name="txt_YiXiangTaoShu"
                                                       placeholder="意向套数" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_YiXiangDanJia">意向单价</label>
                                                <input type="text" class="form-control" id="txt_YiXiangDanJia" name="txt_YiXiangDanJia"
                                                       placeholder="意向单价" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_YiXiangZongJia">意向总价</label>
                                                <input type="text" class="form-control" id="txt_YiXiangZongJia" name="txt_YiXiangZongJia"
                                                       placeholder="意向总价" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_GuanZhuNeiRong">关注内容</label>
                                                <input type="text" class="form-control" id="txt_GuanZhuNeiRong" name="txt_GuanZhuNeiRong"
                                                       placeholder="关注内容" autocomplete="off">
                                            </div>
                                            <div class="form-group col-sm-3">
                                                <label class="col-form-label" for="for_GuanZhuNeiRong">客户来源</label>
                                                <select class="form-control" id="slt_kehulaiyuan" name="" data-fv-notempty="true" data-fv-field="requiredSelect">
                                                    <option value='案场'>案场</option>
                                                    <option value='渠道'>渠道</option>
                                                    <option value='自拓'>自拓</option>
                                                    <option value='全民经纪人'>全民经纪人</option>
                                                    <option value='其他'>其他</option>
                                                </select>
                                            </div>
                                            <div class="form-group" style="padding-top:27px">
                                                <button type="button" class="btn btn-primary" onclick="Add();">确定</button>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>